package com.party.core.service.copartner.impl;

import com.google.common.base.Strings;
import com.party.common.paging.Page;
import com.party.core.dao.read.copartner.CopartnerLevelReadDao;
import com.party.core.dao.write.copartner.CopartnerLevelWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.copartner.CopartnerLevel;
import com.party.core.model.copartner.CopartnerLevelInput;
import com.party.core.model.copartner.CopartnerLevelOutput;
import com.party.core.service.copartner.ICopartnerLevelService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * @Author: Administrator.
 * @Description: 目标与合伙人关联表(二级)
 * @Date:Created in 2018/10/1 0023 下午 15:41.
 */
@Service
public class CopartnerLevelService implements ICopartnerLevelService {
    @Autowired
    private CopartnerLevelReadDao copartnerLevelReadDao;
    @Autowired
    private CopartnerLevelWriteDao copartnerLevelWriteDao;

    @Override
    public String insert(CopartnerLevel copartnerLevel) {
        BaseModel.preInsert(copartnerLevel);
        boolean result = copartnerLevelWriteDao.insert(copartnerLevel);
        if (result) {
            return copartnerLevel.getId();
        }
        return null;
    }

    @Override
    public boolean update(CopartnerLevel copartnerLevel) {
        copartnerLevel.setUpdateDate(new Date());
        return copartnerLevelWriteDao.update(copartnerLevel);
    }

    @Override
    public boolean deleteLogic(String id) {
        if (Strings.isNullOrEmpty(id)) {
            return false;
        }
        return copartnerLevelWriteDao.deleteLogic(id);
    }

    @Override
    public boolean delete(String id) {
        if (Strings.isNullOrEmpty(id)) {
            return false;
        }
        return copartnerLevelWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return false;
        }
        return copartnerLevelWriteDao.batchDeleteLogic(ids);
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return false;
        }
        return copartnerLevelWriteDao.batchDelete(ids);
    }

    @Override
    public CopartnerLevel get(String id) {
      return   copartnerLevelReadDao.get(id);
    }

    @Override
    public List<CopartnerLevel> listPage(CopartnerLevel copartnerLevel, Page page) {
        return null;
    }

    @Override
    public List<CopartnerLevel> list(CopartnerLevel copartnerLevel) {
        return null;
    }

    @Override
    public List<CopartnerLevel> batchList(Set<String> ids, CopartnerLevel copartnerLevel, Page page) {
        return null;
    }

    @Override
    public List<CopartnerLevel> getCopartnerLevelByMultiple(CopartnerLevel copartnerLevel) {
        return copartnerLevelReadDao.getCopartnerLevelByMultiple(copartnerLevel);
    }

    @Override
    public CopartnerLevel findByMemberId(String memberId) {

        return copartnerLevelReadDao.findByMemberId(memberId);
    }

    @Override
    public List<CopartnerLevelOutput> getJuniorPartners(CopartnerLevelInput copartnerLevelInput, Page page) {
        return copartnerLevelReadDao.getJuniorPartners(copartnerLevelInput,page);
    }

    @Override
    public Integer getJuniorPartnersTotal(CopartnerLevelInput copartnerLevelInput) {
        return copartnerLevelReadDao.getJuniorPartnersTotal(copartnerLevelInput);
    }

    @Override
    public Double getPromoteOrLowerToMoney(CopartnerLevelInput copartnerLevelInput) {
        return copartnerLevelReadDao.getPromoteOrLowerToMoney(copartnerLevelInput);
    }

    @Override
    public List<CopartnerLevelOutput> copartnerList(Map<String, Object> params, Page page) {
        return copartnerLevelReadDao.copartnerList(params, page);
    }
}
